/*2：修改课堂上计算平均课时的那题:输入总课时和课程数,
计算平均课时.要求捕捉输入和除法错误;如果总课时少于100,抛出课时太少的错误
*/
package Work0518;

import java.util.InputMismatchException;
import java.util.Scanner;

public class CalculateClassHours {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		try {
			System.out.print("输入总课时(小时):");
			int a = in.nextInt();
			if (a < 100) {
				throw new Exception();
			}
			System.out.print("输入总课程(节):");
			int b = in.nextInt();
			double avg = a / b;
			System.out.println("每节课的平均课时为:" + avg);
		} catch (InputMismatchException ex) {
			System.out.println("输入的不是数字");
			ex.printStackTrace();
		} catch (ArithmeticException ex) {
			System.out.println("课程数不能为零");
			ex.printStackTrace();
		} catch (Exception ex) {
			System.out.println("课程数量太少");
			ex.printStackTrace();
		} finally {
			System.out.println("谢谢");
		}

	}

}
